<?php
/*
+-----------------------------------------------------------------------------+
| $Id: *.php 2009-08-18 08:41:22Z Bleakwind $
| Copyright (c) 2003-2009 Bleakwind (www.weaverdream.com)
| http://www.weaverdream.com/
+-----------------------------------------------------------------------------+
*/

if (!defined( 'ENTRY_INDEX')) {
    echo "<h1>Forbidden</h1><p>You don't have permission to access on this server.</p>";
    exit;
}

// Parse path
if (empty($new_template)) {
    $CONFIGURE['common']['template_filename']       = $sys->get['act'].".htm";

    $CONFIGURE['common']['sub_path']                = "";

    $CONFIGURE['common']['template_path']           = $CONFIGURE['common']['sub_path']."/";
    $CONFIGURE['common']['template_path_filename']  = $CONFIGURE['common']['sub_path']."/".$CONFIGURE['common']['template_filename'];

    $template_name                                  = substr($CONFIGURE['common']['template_path_filename'], 1);
} else {
    $CONFIGURE['common']['sub_split']               = explode("/", $new_template);
    $CONFIGURE['common']['template_filename']       = end($CONFIGURE['common']['sub_split']);

    $CONFIGURE['common']['sub_path_split']          = $CONFIGURE['common']['sub_split'];
    array_pop($CONFIGURE['common']['sub_path_split']);
    if (!empty($CONFIGURE['common']['sub_path_split'])) {
        $CONFIGURE['common']['sub_path']            = "/".implode("/", $CONFIGURE['common']['sub_path_split'])."/";
    } else {
        $CONFIGURE['common']['sub_path']            = "";
    }

    if (substr($CONFIGURE['common']['template_filename'], -4, 4) == ".htm") {
        $new_css    = $CONFIGURE['common']['sub_path']."{\$dir_css}/".substr($CONFIGURE['common']['template_filename'], 0, -4).".css";
        $new_js    = $CONFIGURE['common']['sub_path']."{\$dir_js}/".substr($CONFIGURE['common']['template_filename'], 0, -4).".js";
    } elseif (substr($CONFIGURE['common']['template_filename'], -5, 5) == ".html") {
        $new_css    = $CONFIGURE['common']['sub_path']."{\$dir_css}/".substr($CONFIGURE['common']['template_filename'], 0, -5).".css";
        $new_js    = $CONFIGURE['common']['sub_path']."{\$dir_js}/".substr($CONFIGURE['common']['template_filename'], 0, -5).".js";
    }

    $CONFIGURE['common']['template_path']           = $CONFIGURE['common']['sub_path']."/";
    $CONFIGURE['common']['template_path_filename']  = $CONFIGURE['common']['sub_path']."/".$CONFIGURE['common']['template_filename'];

    $template_name                                  = substr($CONFIGURE['common']['template_path_filename'], 1);
}
$public_var['dir_template'] = "template/".$TEMPLATE[$CONFIG['template']]['dir'];
$public_var['dir_images']   = "template/".$TEMPLATE[$CONFIG['template']]['dir']."/{\$dir_images}";
$public_var['dir_css']      = "template/".$TEMPLATE[$CONFIG['template']]['dir']."/{\$dir_css}";
$public_var['dir_js']       = "template/".$TEMPLATE[$CONFIG['template']]['dir']."/{\$dir_js}";
$public_var['dir_flash']    = "template/".$TEMPLATE[$CONFIG['template']]['dir']."/{\$dir_flash}";
$SETTING['dir_template']    = "template/".$TEMPLATE[$CONFIG['template']]['dir'];
$SETTING['dir_images']      = "template/".$TEMPLATE[$CONFIG['template']]['dir']."/{\$dir_images}";
$SETTING['dir_css']         = "template/".$TEMPLATE[$CONFIG['template']]['dir']."/{\$dir_css}";
$SETTING['dir_js']          = "template/".$TEMPLATE[$CONFIG['template']]['dir']."/{\$dir_js}";
$SETTING['dir_flash']       = "template/".$TEMPLATE[$CONFIG['template']]['dir']."/{\$dir_flash}";
?>